import request from '@/utils/request'
import requestFile from '@/utils/request-file'

const prefixUrl = 'web/workOrder'
const repairUrl = 'web/worker_repair'
import qs from 'qs'

// 列表
export function list(params) {
  return request({
    url: prefixUrl + '/list',
    method: 'get',
    params: params,
    paramsSerializer: params => {
      return qs.stringify(params, {
        indices: false
      })
    }
  })
}

// 工人提交列表
export function submit_list(params) {
  return request({
    url: prefixUrl + '/submit_list',
    method: 'get',
    params
  })
}

// 获取销售单列表
export function listBillSale(params) {
  return request({
    url: prefixUrl + '/listBillSale',
    method: 'get',
    params
  })
}

// 获取楼盘列表
export function listPageBuilding(params) {
  return request({
    url: prefixUrl + '/listPageBuilding',
    method: 'get',
    params
  })
}

// 获取每个工单总数
export function listWorkOrderNumOfType(params) {
  return request({
    url: prefixUrl + '/listWorkOrderNumOfType',
    method: 'get',
    params
  })
}

// 关闭
export function handClosed(params) {
  return request({
    url: prefixUrl + '/handClosed',
    method: 'delete',
    params
  })
}

// 删除
export function remove(params) {
  return request({
    url: prefixUrl + '/delete',
    method: 'delete',
    params
  })
}

// 根据楼盘列表获取销售单数据
export function listBuildingOfBillSale(params) {
  return request({
    url: prefixUrl + '/listBuildingOfBillSale',
    method: 'get',
    params
  })
}

// 楼盘分配工人
export function listBuildingMacthWorker(data) {
  return request({
    url: prefixUrl + '/listBuildingMacthWorker',
    method: 'post',
    content_type: 'json',
    data: data
  })
}

// 获取工人信息
export function listWorker(params) {
  return request({
    url: prefixUrl + '/listWorker',
    method: 'get',
    params
  })
}

// 保存
export function save(data) {
  return request({
    url: prefixUrl + '/save',
    method: 'post',
    content_type: 'json',
    data
  })
}

// 修改
export function edit(data) {
  return request({
    url: prefixUrl + '/edit',
    method: 'post',
    content_type: 'json',
    data
  })
}

// 修改截止时间
export function editDeadline(data) {
  return request({
    url: prefixUrl + `/editDeadline`,
    method: 'post',
    data: data,
    content_type: 'json'
  })
}

// 获取详情
export function detail(id) {
  return request({
    url: prefixUrl + '/detail/' + id,
    method: 'get'
  })
}

// 生成报告
export function genWorkOrderReport(data) {
  return request({
    url: prefixUrl + '/genWorkOrderReport',
    method: 'post',
    content_type: 'json',
    data
  })
}

// 获取进度详情
export function listProcessOfBuilding(params) {
  return request({
    url: prefixUrl + '/listProcessOfBuilding',
    method: 'get',
    params
  })
}

// 获取进度详情
export function getWorkOrderSubmissionByBuildingId(params) {
  return request({
    url: prefixUrl + '/getWorkOrderSubmissionByBuildingId',
    method: 'get',
    params
  })
}

// 获取待维修设备列表
export function getWorkRepairOrderList(params) {
  return request({
    url: repairUrl + '/list',
    method: 'get',
    params
  })
}

export function getWorkerRepairTotal(params){
  return request({
    url: repairUrl + '/total',
    method: 'get',
    params
  })
}

// 提交维修工单
export function submit(data) {
  return request({
    url: repairUrl + '/submit',
    method: 'post',
    content_type: 'json',
    data
  })
}

// 获取空闲点位列表
export function getUnlockedPoint(params) {
  return request({
    url: prefixUrl + '/getUnlockedPoint',
    method: 'get',
    params
  })
}

// 工单替换点位
export function replacePoint(data) {
  return request({
    url: prefixUrl + '/replacePoint',
    method: 'post',
    content_type: 'json',
    data
  })
}

// 工单批量替换点位
export function batchReplacePoint(data) {
  return request({
    url: prefixUrl + '/batchReplacePoint',
    method: 'post',
    content_type: 'json',
    data
  })
}

// 获取合同上刊情况
export function query_contract_point_publish_info(params) {
  return request({
    url: prefixUrl + '/query-contract-point-publish-info',
    method: 'get',
    params
  })
}

// 根据工单类型获取工单进度
export function getAllWorkOrderProgressByTypeId(params) {
  return request({
    url: prefixUrl + '/getAllWorkOrderProgressByTypeId',
    method: 'get',
    params
  })
}

// 列表
export function allList(params) {
  return request({
    url: prefixUrl + '/allList',
    method: 'get',
    params
  })
}

// 生成图片包
export function createImgPackage(params) {
  return request({
    url: prefixUrl + '/createImgPackage',
    method: 'get',
    params
  })
}

export function export_work_order_point_detail(params) {
  return requestFile({
    url: prefixUrl + '/export_work_order_point_detail',
    method: 'get',
    params,
    fileName: '工单详细点位导出模板.xls'
  })
}

// 全选楼盘
export function allSelectBuildingList(params) {
  return request({
    url: prefixUrl + '/allSelectBuildingList',
    method: 'get',
    params
  })
}

// 分配工人
export function assignWorkers(data) {
  return request({
    url: prefixUrl + '/assignWorkers',
    method: 'post',
    data,
    content_type: 'json'
  })
}


